<?php
$aMenuPosition = unserialize(PAGE_POSITION_TEXT);
$aPageTemplateName = getTemplateName(PAGE_TEMPLATE_DIR);
?>
<div class="row">
	<div class="col-md-12">
		<h1>
            <p class="pull-left">Trang <small>Quản lý các trang trên Menu chính, footer</small></p>
            <p class="pull-right">
                <a class="btn btn-primary" href="<?php echo admin_page_url(PAGE_SLUG.'/them-moi'); ?>"><i class="glyphicon glyphicon-plus-sign"></i> Thêm mới</a>
                <button type="button" class="btn btn-success" onclick="wireOfAction('#btn-submit', 'click');">
                    <i class='glyphicon glyphicon-ok-sign'></i>&nbsp;Hoàn tất
                </button>
                <a class="btn btn-default" href="<?php echo admin_page_url(PAGE_SLUG); ?>"><i class='glyphicon glyphicon-share-alt'></i>&nbsp;Trở về</a>
            </p>
        </h1>
    </div>

    <div class="col-md-12 col-xs-12">
        <ol class="breadcrumb">
            <li><a href="<?php echo admin_page_url(); ?>"><i class="fa fa-dashboard"></i> Dashboard</a></li>
            <li><a href="<?php echo admin_page_url(PAGE_SLUG); ?>"><i class="fa fa-table"></i> Danh sách các trang hiện có</a></li>
        </ol>
    </div>
</div>

<div class='row' id="panel-new-page">
    <h1 class="col-md-12"><?php echo $breadcrumbTitle; ?></h1>
    <form role="form" method="post" action="<?php echo $action; ?>" data-callback='1'>
        <div class="form-group col-md-12 col-xs-12">
            <label for="input-page-title">Tên trang</label>
            <input type="text" class="form-control auto-slug"
                follow-ctr='#input-page-slug' id="input-page-title" name="page[title]" value="<?php echo $oPage->getTitle(); ?>" />
        </div>

        <div class="form-group col-md-12 col-xs-12">
            <label for="input-page-slug">Đường dẫn</label>
            <input type="text" class="form-control" id="input-page-slug" name="page[slug]" value="<?php echo $oPage->getSlug(); ?>" />
        </div>

        <div class="form-group col-md-9 col-xs-12">
            <label for="input-page-content">Nội dung trang</label>
            <textarea class="ckeditor" id="input-page-content" name="page[content]" rows="10"><?php echo $oPage->getContent(); ?></textarea>
        </div>

        <div class="col-md-3 col-xs-12">
            <div class="form-group">
                <label for="input-page-position">Nhóm menu</label>
                <select class="form-control" id="input-page-position" name="page[position]">
                    <?php foreach($aMenuPosition as $key=>$text){ ?>
                    <option value="<?php echo $key; ?>" <?php echo $oPage->getPosition()==$key?"selected='selected'":""; ?> ><?php echo $text; ?></option>
                    <?php } ?>
                </select>
            </div>
            <div class="form-group">
                <label for="input-page-order">Thứ tự trên menu</label>
                <input type="text" class="form-control" id="input-page-order" name="page[order]" value="<?php echo $oPage->getOrder(); ?>" />
            </div>
            <div class="form-group">
                <label for="input-page-template">Tên file template thay thế</label>
                <select class="form-control" id="input-page-template" name="page[template]">
                    <option value="">-</option>
                    <?php foreach($aPageTemplateName as $pn) { ?>
                    <option value="<?php echo $pn; ?>" <?php echo $oPage->getTemplate()==$pn?"selected='selected'":""; ?> ><?php echo $pn; ?></option>
                    <?php } ?>
                </select>
            </div>
            <div class="form-group">
                <div class="checkbox">
                    <label for="input-page-publish-flg">
                        <input type="checkbox" id="input-page-publish-flg" name="page[publish_flg]" value="1"
                        <?php echo $oPage->getPublishFlg()==ON?'checked="checked"':''; ?> />Hiển thị
                    </label>
                </div>
            </div>
            <div class="form-group">
                <?php if($action==admin_page_url(PAGE_SLUG.'/cap-nhat/do')) { ?>
                <input type="hidden" name="page[case]" value="<?php echo UPDATE_FULL; ?>" />
                <input type="hidden" name="page[id]" value="<?php echo $this->encrypt->encode($oPage->getId()); ?>" />
                <?php } ?>
                <button type="button" class="btn btn-success btn-submit-update" id="btn-submit"><i class='glyphicon glyphicon-ok-sign'></i>&nbsp;Hoàn tất</button>&nbsp;
                <a class="btn btn-default" href="<?php echo admin_page_url(PAGE_SLUG); ?>"><i class='glyphicon glyphicon-share-alt'></i>&nbsp;Trở về</a>
            </div>
        </div>
    </form>
</div>